const { create } = require("../server/uploadServer.js")

class UploadController {
	async create(ctx, next) {
        const {files} = ctx.request
        const {user_id , journal_id} = ctx.request.body
        let photoData = files.map(item => {
            const {filename , mimetype , size} = item
            return [
                filename , mimetype , size , user_id , journal_id
            ]
        })
        console.log("photoData" , photoData);
        const resulst = await create(photoData)
        console.log(resulst);
        if(!resulst.insertId){
            console.log('上传失败');
        }
        ctx.body ={
            code:0,
            message:"上传成功",
            resulst
        }
    }
}

module.exports = new UploadController();
